{include file="header"}
<script src="/xcxmb/publpic/static/js/ckeditor/ckeditor.js"></script>
<div class="body">
	<div class="nav">
		<div class="addbtn"></div>
		<a href="index">首页</a> > <a href="?app=first&act=index">首页管理</a> > 修改
	</div>
		<form class="checkform" action="update" method="post">
		<input type="hidden" name="id" id="id" value="{$row.id}" />
		<br>
		<table class="tap" width="100%" border="0" cellspacing="0" cellpadding="0">
		

			<tr>
				<td width="160" class="gra" align="center" height="50">标题</td>
				<td><input title="" type="text" name="title" id="title" value="{$row.title}" class="binput coo-need" />
				</td>
			</tr>
			<tr>
				<td width="160" class="gra" align="center" height="50">作者</td>
				<td><input title="" type="text" name="writer" id="writer" value="{$row.writer}" class="binput coo-need" />
				</td>
			</tr>
			<tr>
				<td width="160" class="gra" align="center" height="50">所属分类</td>
				<td>
					<select name="type_id">
						<option value="">全部分类</option>
						{foreach name="type" item="t"}
							<option value="{$t.id}" {if $t.id==$row.type_id}selected{/if}>{$t.name}</option>
						{/foreach}
					</select>
				</td>
			</tr>
			<tr>
				<td width="160" class="gra" align="center">封面图片</td>
				<td>
				<table><tr><td height="60">
						<input type="hidden" name="origin_pic" value="{$row.pic}" />
						<input type="text" name="pic" id="pic" value="{$row.pic}" />
						<!-- <input type="file" name="pic" id="pic" value="{$row.pic}" /> -->
						<font color="gray"><i>尺寸为640x220像素</i></font>
					</td>
					<td>
					{if $row.pic}<p><img src="{$row.pic}" height="100" /></p>{/if}
					</td>
				</tr></table>
				</td>
			</tr>
			
			<tr>
				<td width="160" class="gra" align="center">内容</td>
				<td>
					<textarea class="ckeditor" name="content" id="content" style="width:80%" rows="20">{$row.content}</textarea>
				</td>
			</tr>	
			<tr>
				<td width="160" class="gra" align="center" height="50">是否显示</td>
				<td>
				<input type="radio" name="status" value="0" {if $row.status==0}checked{/if} />是
				 <input type="radio" name="status" value="1" {if $row.status==1}checked{/if} />否
				</td>
			</tr>			
			<tr>
				<td width="160" class="gra" align="center" height="50">排序</td>
				<td><input type="text" name="sort" id="sort" value="{$row.sort}" class="binput coo-need" />
					<span class="gray">数字越小，排在越前</span>
				</td>
			</tr>
			<tr>
				<td width="160" class="gra" align="center">点击量</td>
				<td><input type="text" name="clicks" id="clicks" value="{$row.clicks}" class="binput" />
				</td>
			</tr>
			<tr class="last">
				<td align="center">&nbsp;</td>
				<td><input type="submit" id="Submit" class="submitbtn" value="提 交" /></td>

			</tr>

		</table>
		</form>
</div>
<script>
    //ajax
    var xhr;
    var now=0;
    function createXMLHttpRequest()
    {
        if(window.ActiveXObject)
        {
            xhr = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else if(window.XMLHttpRequest)
        {
            xhr = new XMLHttpRequest();
        }
    }
    function UploadFile()
    {
        if($('#imgs').children().length>=3){
            alert("图片不可超过3张");
        }
        else{
            var fileObj = document.getElementById("pic_file").files[0];
            var FileController = '?app=first&act=upload_pic';
            var form = new FormData();
            form.append("pic_file", fileObj);
            createXMLHttpRequest();
            xhr.onreadystatechange = handleStateChange;
            xhr.open("post", FileController, true);
            xhr.send(form);
        }
    }

    function handleStateChange()
    {
        if(xhr.readyState == 4)
        {
            if (xhr.status == 200 || xhr.status == 0)
            {
                var result = xhr.responseText;
                document.getElementById("imgs").innerHTML+="<div id='"+now+"' style='float:left;position:relative;margin-right:10px;'>"
                        +"<img src='"+result+"' width='158' height='256' style='margin-top:10px;'>"+
                        "<input type='hidden' name='pics[]'  value='"+result+"' /><br>"+
                        "排序<input type='text' name='sort_pic[]'  value='"+999+"' /><br>"+
                        "<a href='###' style='position:absolute;right:-5.5px;top:1.5px;' onclick='onDel("+now+");'><img src='/images/horum_img_delete.png' width='20' height='20'></a></div>";
                if($('#imgs').children().length>=4){
                    $('#file').hide();//('display','hidden');
                }
            }
        }
    }
    function onDel(id)
    {
        if(confirm("是否删除？")){
            var picdiv = document.getElementById(id);
            picdiv.parentNode.removeChild(picdiv);
            if($('#imgs').children().length<4){
                $('#file').show();//('display','hidden');
            }
        }else
        {
            return false;
        }
    }
</script>
{include file="footer"}